﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace PSLibrary.Utils
{
    public static class CheckCodes
    {
        public static Char CheckDNI(String dni)
        {
            string Letters = "TRWAGMYFPDXBNJZSQVHLCKE";

            if (new Regex("[0-9]{8}").Match(dni).Success)
            {
                return Letters[System.Convert.ToInt32((System.Convert.ToInt64(dni.Substring(0, 8)) % 23))];
            }
            else
            {
                return ' ';
            }
        }
    }
}
